#include<iostream>
#include<vector>
#include<queue>

using namespace std;


class Solution {
public:
    int triangleNumber(vector<int>& nums) {

        int count = 0;
        sort(nums.begin(), nums.end(), less<int>());
        for (int i = nums.size() - 1; i >= 2; i--) {
            int left = 0;
            int right = i - 1;
            while (left != right) {
                if ((nums[left] + nums[right]) > nums[i]) {
                    count += right - left;
                    right--;
                }
                else {
                    left++;
                }
            }
        }
        return count;
    }
};


int main()
{
    return 0;
}